package zpx.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.compass.core.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zpx.dao.FtpAttachmentDao;
import zpx.iservice.IFtpAttachmentService;
import zpx.model.FtpAttachment;
import zpx.model.User;



/**
  ftp�߼������ӿ�ʵ����
 */

@Service("ftpAttachmentService")
public class FtpAttachmentService implements IFtpAttachmentService{

	private  FtpAttachmentDao ftpAttachmentDao;
	
	public FtpAttachmentDao getFtpAttachmentDao() {
		return ftpAttachmentDao;
	}

	@Autowired
	public void setFtpAttachmentDao(FtpAttachmentDao ftpAttachmentDao) {
		this.ftpAttachmentDao = ftpAttachmentDao;
	}
	
	@Override
	public int getFtpCount(Map<String, Object> searchMap) {
		return this.ftpAttachmentDao.getFtpttachmentsCount(searchMap);
	}
	
	@Override
	public List<FtpAttachment> getAttachments(String recordId) {
		return this.ftpAttachmentDao.getAttachments(recordId);
	}

	@Override
	public List<FtpAttachment> getFtpttachmentsLst(Map<String, Object> searchMap) {
		return this.ftpAttachmentDao.getFtpttachmentsLst(searchMap);
	}

	@Override
	public FtpAttachment getFtpAttachment(String attaId) {
		return ftpAttachmentDao.getFtpAttachment(attaId);
	}

	

	@Override
	public void deleteFtpAttachment(String attaId) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public FtpAttachment saveOrUpdateFtpAttachment(Map<String, Object> searchMap) {
		FtpAttachment ftpAttachment=(FtpAttachment) searchMap.get("ftpAttachment");
		User loginUser=(User) searchMap.get("loginUser");
		if(StringUtils.hasText(ftpAttachment.getAttaId())){
			ftpAttachment.setUpdateDate(new Date());
			ftpAttachment.setUpdatePerson(loginUser.getId());
		}else {
			ftpAttachment.setCreateDate(new Date());
			ftpAttachment.setCreatePerson(loginUser.getId());
		}
		return ftpAttachmentDao.saveOrUpdateFtpAttachment(ftpAttachment);
	}

	

	

}
